%macro get_zips;

	proc printto new log = "&logdir./get_zips.txt";
	run;

		/****************************************
		*										*
		*			Start PROC SQL				*
		*										*
		****************************************/
		proc sql noprint;
		[redacted] (
				
				
				select
					[redacted] as zip,
					case when [redacted] = 11 then 1 else 0 end 
						as washington,
					case when [redacted] = 36
						and [redacted] in(47,81,5,61,85) then 1 else 0 end
						as new_york,
					case when [redacted] = 6 
						and [redacted] = 37 then 1 else 0 end 
						as los_angeles,
					case when [redacted] = 53 
						and [redacted] = 33 
						and upper([redacted]) = "SEATTLE" then 1 else 0 end
						as seattle,
					case when [redacted] = 17
						and [redacted] = 31
						and upper([redacted]) = "CHICAGO" then 1 else 0 end
						as chicago,
					case when [redacted] = 42
						and [redacted] = 101 then 1 else 0 end
						as philadelphia,
					case when [redacted] = 6 
						and [redacted] = 75 then 1 else 0 end
						as san_francisco
				from [redacted]
				where washington = 1
					or new_york = 1
					or los_angeles = 1
					or seattle = 1
					or chicago = 1
					or philadelphia = 1
					or san_francisco = 1
				order by zip
			);
	disconnect from iq;
	quit;
	
	data rlib.zips;
		set sample;
		/* start with the longest name! */
		if san_francisco then city = "SAN FRANCISCO";
		if new_york then city      = "NEW YORK";
		if washington then city    = "WASHINGTON";
		if los_angeles then city   = "LOS ANGELES";
		if seattle then city       = "SEATTLE";
		if chicago then city       = "CHICAGO";
		if philadelphia then city  = "PHILADELPHIA";
		keep zip city;
	run;
	
	proc printto;
	run;
%mend;

